#include <2025Linux.h>
int main(int argc, char *argv[])
{
    // ./07_dup file1
    ARGS_CHECK(argc,2);
    int oldfd = open(argv[1],O_RDWR);
    ERROR_CHECK(oldfd,-1,"open");
    printf("oldfd = %d\n", oldfd);
    int newfd = dup(oldfd);
    printf("newfd = %d\n", newfd); //oldfd和newfd数值不同
    //newfd的数值是所有文件描述符中，最小可用
    
    write(oldfd,"hello",5);
    write(newfd,"world",5);
    return 0;
}

